package main

func canJump(nums []int) bool {
	max := 0
	for i := 0; i <= max && i < len(nums); i++ {
		n := i + nums[i]
		if n > max {
			max = n
		}
	}
	return max >= len(nums)-1
}

func main() {
	println(canJump([]int{2, 3, 1, 1, 4}))
	println(canJump([]int{3, 2, 1, 0, 4}))
}
